<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/derek-tags" prefix="dk"%>
<dk:WarPath />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>

		<title>计划工具</title>
		<link rel="stylesheet" type="text/css" href="${_WarPath }/css/Main.css" />
		<link rel="stylesheet" type="text/css" href="${_WarPath }/css/dialog.css" />
		<link rel="stylesheet" type="text/css" href="${_WarPath}/css/power_modify.css" />
		<link href="${_WarPath }/css/base.css" type=text/css rel=stylesheet />
		<link href="${_WarPath }/css/account.css" type=text/css rel=stylesheet />
		<link rel=stylesheet type=text/css href="${_WarPath }/css/jquery.alerts.css" media=screen />
		
		<script src="${_WarPath }/js/jquery-1.4.js" type="text/javascript"></script>
		<script type="text/javascript" src="js/ct.js"></script>
		<script type="text/javascript" src="js/popupDiv.js"></script>
		<script src="${_WarPath }/js/calendar.js" type="text/javascript"></script>
		<script src="${_WarPath }/js/calendar-en.js" type="text/javascript"></script>
		<script src="${_WarPath }/js/calendar-setup.js" type="text/javascript"></script>
		<link rel="stylesheet" type="text/css" media="all" href="${_WarPath }/css/calendar-blue2.css" />
		<script src="${_WarPath }/jsp/user/login.js" type="text/javascript"></script>
	<style type="text/css">
<!--
body {margin:0px;}
.itd0 {
	font-size:14px;
	color: #FFFFFF;
	text-align: center;
	background-color: #CC0000;
}
.itd1 {
	font-size:14px;
	color: #333333;
	text-align: center;
	background-color: #FFFFFF;
	width: 14%;
}
.itd2 {
	font-size:14px;
	color: #333333;
	text-align: center;
	background-color: #EEEEEE;
}
.ititle {
	font-size: 16px;
	font-weight: bold;
	color: #CC0000;
	line-height: 150%;
}
.itab {
	border:1px #CC0000 solid;
	background-color:#FFFFFF;
	margin-bottom:8px;
}
.itab td,input {
	font-size:14px;
}

-->
</style>
<script language="javascript" type="text/javascript">
function doClick()
{
	var bb = document.getElementById("submit");
	var showTab = document.getElementById("showTab");
	bb.value = "正在计算..";
	bb.disabled = true;
	while(showTab.rows.length > 1) showTab.deleteRow(showTab.rows.length - 1); //清空表格
	setTimeout("show();var bb = document.getElementById(\"submit\");bb.disabled = false;bb.value = \" 计 算 \"",500);
}

function show()
{
	if(!checkValue()) return;
	var sTr = "";
	var sq = Number(document.getElementById("sq").value);
	var sz = Number(document.getElementById("sz").value);
	var sb = Number(document.getElementById("sb").value);
	var maxBei = Number(document.getElementById("sbMax").value);//合理倍投的最大值
	var dj = Number(document.getElementById("dj").value);
	var qi = Number(document.getElementById("qi").value);
	var syType = (document.getElementById("syType2").checked) ? false : true;
	var sy = (syType) ? Number(document.getElementById("sy1").value) : Number(document.getElementById("sy2").value);
	var showTab = document.getElementById("showTab");
	var baseTr =showTab.rows[0];
	var tempSy;
	var tempTr = 0;
	var thisTr,thisCell;
	var vArr = new Array(7);
	
	for(var i = 1;i <= sq;i++)
	{
		if(syType == false && i == (qi + 1)) sy = Number(document.getElementById("sy3").value);
		while(((((dj * sb) - (tempTr + (sz * sb * 2))) * 100) / (tempTr + (sz * sb * 2))) < sy)
		{
			if(sb > maxBei)
			{
				alert("按照当前设置，从第" + i + "期开始，投注倍数将超过" + maxBei + "倍，建议从以下方面调整方案\n\n1.减少方案期数(推荐)\n2.降低预期收益率(推荐)\n3.减少投入注数\n4.提高最大倍数设置");
				return;
			}
			sb++;
		}
		tempTr += (sz * sb * 2);
		tempSy = ((dj * sb) - tempTr) * 100 / tempTr;
		vArr[0] = i.toString();
		vArr[1] = sb.toString();
		vArr[2] = (sz * sb * 2).toString();
		vArr[3] = tempTr.toString();
		vArr[4] = (dj * sb).toString();
		vArr[5] = ((dj * sb) - tempTr).toString();
		vArr[6] = tempSy.toFixed(2) + "%";
		thisTr = showTab.insertRow(-1);
		for(var ii = 0;ii < baseTr.cells.length;ii++)
		{
			thisCell = thisTr.insertCell(ii);
			thisCell.className = (i % 2 == 0) ? "itd2" : "itd1";
			thisCell.innerHTML = vArr[ii];
		}
	}
}
function changeType()
{
	var syType1 = document.getElementById("syType1");
	var sy1 = document.getElementById("sy1");
	var sy2 = document.getElementById("sy2");
	var sy3 = document.getElementById("sy3");
	var qi = document.getElementById("qi");
	sy1.disabled = !syType1.checked;
	sy2.disabled = syType1.checked;
	sy3.disabled = syType1.checked;
	qi.disabled = syType1.checked;
}
function checkValue()
{
	var showTab = document.getElementById("showTab");
	var inputArr = document.getElementsByName("dataInput");
	var re = /[^\d]+/ig;
	for(var i = 0;i < inputArr.length;i++)
	{
		if(re.test(inputArr[i].value))
		{
			alert("数值必须为正整数");
			inputArr[i].select();
			return false;
		}
	}
	return true;
}
</script>
	</head>

	<body>

		<div id="content_bg" align="center">
			<div id="warpper">
				<div id="content">
					<div id="header">
						<%@ include file="../frame/top.jsp"%>
					</div>
					<div id="mainBody">
						<%@ include file="jhgj_main.jsp"%>
					</div>
					<div id="footer">
						<%@ include file="../frame/footer.jsp"%>
					</div>

				</div>
			</div>
		</div>

	</body>
</html>
